package com.by.service.impl;

import com.by.bean.ResultBean;
import com.by.mapper.SupplierContactMapper;
import com.by.service.SupplierContactService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author :LYJ
 * @version : 1.0
 * @date : 2025/2/21 14:53
 * @desc :
 * @since : JDK17
 */
@Service
public class SupplierContactServiceImpl implements SupplierContactService {
    @Autowired
    SupplierContactMapper supplierContactMapper;

    /**
     * 重置密码
     *
     * @param id
     * @return
     */
    @Override
    public ResultBean resetPassword(int id) {
        //1.根据id获取账户
        String account = supplierContactMapper.findAccountById(id);
        if (account == null || account.isEmpty()) {
            return ResultBean.fail("重置失败");
        }
        //2.根据查询到的账户重置密码
        int res = supplierContactMapper.resetPassword(account);
        if (res == 0) {
            return ResultBean.fail("重置失败");
        }
        return ResultBean.success("重置成功");
    }
}
